package g3pd.gradep.virdgm;

import org.isam.exehda.Exehda;
import org.isam.exehda.HostId;
import org.isam.exehda.ObjectId;
import org.isam.exehda.ResourceName;
import org.isam.exehda.services.CellInformationBase;
import org.isam.exehda.services.Worb;
import org.isam.exehda.services.ObjectSeed.Activator;
import org.isam.exehda.services.ObjectSeed.MarshaledOX;

public class VirdActivator implements Activator {
    private static final long serialVersionUID = -8210755766364099469L;
    
    public void activate(ObjectId oxID, Object obj, MarshaledOX extState) throws Exception {
        VirdExecImpl procExecImpl = (VirdExecImpl) obj;
        Worb worb = (Worb) Exehda.getService(Worb.SERVICE_NAME);
        CellInformationBase cib = (CellInformationBase) Exehda.getService(CellInformationBase.SERVICE_NAME);
        
        String serviceURI = worb.exportService(procExecImpl, VirdExec.class, "ProcExec");
                
        ResourceName procExecName = HostId.getLocalHost().toResourceName();
        cib.addResource(procExecName);
        cib.setAttribute(procExecName, "contactAddress"+oxID.toResourceName().toString(), serviceURI);
    }
    
    public void deactivate(ObjectId oxID, Object obj, MarshaledOX extState) throws Exception {
        
    }
}